import Vue from 'vue'
import Router from 'vue-router'
import {constantRouterMap} from '@/router/router.config'

// hack router push callback
// 解决重复跳转路由问题
const originalPush = Router.prototype.push
Router.prototype.push = function push (location, onResolve, onReject) {
  if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(Router)
export default new Router({
    // mode: 'history', // 使用精准url地址模式，默认是hash模式
    routes: constantRouterMap
})